"""
构建地图
"""

from pyecharts.charts import Map
from pyecharts.options import *

# 构建地图对象
map = Map()
# 准备数据
data = [("北京市",99),
        ("上海市",199),
        ("湖南省",299),
        ("台湾省",499),
        ("安徽省",599),
        ("广州省",699),
        ("湖北省",799)
        ]
# 添加数据
# 第一个参数：名称
# 第二个参数：数据
# 第三个参数：地图类型
map.add("地图",data,"china")

# 设置全局选项
map.set_global_opts(
    visualmap_opts = VisualMapOpts(
        is_show=True,
        # 开启手动校准范围
        is_piecewise=True,
        pieces=[
            {"min":1,"max":9,"label":"1-9人","color":"#CCFFFF"},
            {"min":10,"max":999,"label":"10-99人","color":"#FFFF99"},
            {"min":100,"max":499,"label":"99-499人","color":"#FF9966"},
            {"min":500,"max":999,"label":"499-999人","color":"#FF6666"},
            {"min":1000,"max":9999,"label":"1000-9999人","color":"#CC3333"},
            {"min":10000,"label":"10000以上","color":"#990033"}
        ]
    )
)

# 绘图
map.render()